package  cn.sm1234.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/*S3.编写控制器*/
//@Controller
@RestController  // 这个注解代替了@controller与@responseBody
//@RequestMapping("/hello")
public class HelloController {
    private Map<String, Object> result = new HashMap<String,Object>();

    @RequestMapping("/hello")
    //@ResponseBody   // 转换JSON注解
    public Map<String, Object> hello(){
        result.put("name", "eric");
        result.put("gender", "male");
        return result;
    }
}

